<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="com.shop.service.ProductService" %>
<%@ page import="com.shop.pojo.Product" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>book</title>
    <link href="CSS/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../../CSS/search.css"/>
</head>
<body>
<h1>书籍</h1>
<%
    //获取容器的业务实例，查询数据库的所有商品显示到页面
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    ProductService productService = context.getBean("productServiceImpl", ProductService.class);
    List<Product> products = productService.queryAllProduct();
    request.setAttribute("products", products);
%>
<div id="all">
    <c:forEach var="product" items="${products}">
        <div class="card">
            <div id="card-in">
                <div class="grid-area grid-area_a grid-thumbnail">
                    <div class="card-thumbnail">
                        <img src="images/${product.image}" alt="">
                    </div>
                </div>
                <div class="grid-area grid-area_b">
                    <h3 class="card-title">${product.productName}</h3>
                    <div class="card-submit">${product.description}</div>
                </div>
                <div class="grid-area grid-area_c">
                    <div class="card-label">
                        <span>爆款促销</span>
                        <span>金币抵2%</span>
                    </div>
                </div>
                <div class="grid-area grid-area_d">
                    <div class="card-price">${product.price}￥</div>
                    <div class="card-action">
                        <button class="but_buy">立即购买</button>
                    </div>
                </div>
            </div>
        </div>
    </c:forEach>
</div>
</body>
</html>
